package com.xyh.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sun.org.apache.regexp.internal.RE;
import com.xyh.po.User;
import com.xyh.service.impl.UserServiceImpl;
import org.apache.ibatis.annotations.ResultMap;
import org.omg.CORBA.Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.Response;
import java.io.IOException;
import java.util.List;

/**
 * @Author:kyle
 * @Date:2020/12/16 - 13:39
 * @Project:spring_demo1
 * @Package:com.xyh.controller
 * @Version:1.0
 */
@Controller
@RequestMapping("/user")
public class HelloHandler implements HttpRequestHandler {

    @Autowired
    private UserServiceImpl userService;

    @Override
    @RequestMapping("/helloHandler")
    public void handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.likeRight("username","张");

        List<User> list = userService.list(wrapper);

        httpServletRequest.setAttribute("handler",list);
        httpServletRequest.getRequestDispatcher("hello").forward(httpServletRequest, httpServletResponse);

    }
}
